#include <stdio.h>

#include "variable_middle.h"
char MAC_DATA[16];
s_type                  s;
Faults_data         faults;
CircleBuffer_t  CirBuf;

uint8_t  get_device_num = 0, show_device_num = 0,  RX_Buffer[2][RX_LEN] = {0},
send_index, current_page_index=0, send_tx_time, send_tx_len,wait_out_time;

UART_TYPE   receve_order0, uart_data0, uart_data_blue, receve_order_blue, Uart_send_data;
uint16_t        stateflag, stateflag_blue, re_send_order, buzzer_time, buzzer_set_time, send_run_time, get_data_time;
uint16_t get_name_time, mac_time,off_line_time;

Send_order_type DEF_Send_order_data =
{
    11,
    {0,},
    {0,},
    {
        GET_SOFT_VER, MAIN_ORDER_A, MAIN_ORDER_B, GET_ERROR,
  			GET_DATE,GET_INFO_A, GET_INFO_B,
			GET_CELL_L1, GET_CELL_L2, GET_CELL_L3,GET_CELL_L4,
    },
		{8,7,7,2,
		3,8,9,
		8,8,8,4,}
};
Send_order_type Send_order_data[4]=
{
	{
		3,
    {0,},
    {0,},
    {
      MAIN_ORDER_A, MAIN_ORDER_B, GET_ERROR,
    },
		{7,7,2}
	},
	{
		2,
    {0,},
    {0,},
    {
      GET_INFO_A, GET_INFO_B,
    },
		{3,8}
	},
	{
		4,
    {0,},
    {0,},
    {
     GET_CELL_L1, GET_CELL_L2, GET_CELL_L3,GET_CELL_L4
    },
		{8,8,8,4}
	},
	{
		2,
    {0,},
    {0,},
    {
     GET_SOFT_VER, GET_DATE, 
    },
		{8,3,}
	}
};

//*******************************************
bms_main_type       bms_main_data;
bms_info_type       bms_info_data ;
bms_version_type    bms_version_data ;
bms_cell_type       bes_cell_data;;
dsp_version_type    dsp_version_data;
ble_device_type Device_list[30];
def_ble_device_type def_device,eeprom_def_device;
//*******************************************
const  char GET_MAC[] = {0x54, 0x54, 0x4D, 0x3A, 0x4D, 0x41, 0x43, 0x2D, 0x3F};
const  char BLE_RESET[] = {0x54, 0x54, 0x4D, 0x3A, 0x52, 0x53, 0x54, 0x2D, 0x53, 0x59, 0x53, 0x54, 0x45, 0x4D, 0x52, 0x45, 0x53, 0x45, 0x54};
const  char BLE_ADD[] = {0x54, 0x54, 0x4D, 0x3A, 0x41, 0x44, 0x44, 0x2D};
const  char BLE_PID[] = {0x54, 0x54, 0x4D, 0x3A, 0x50, 0x49, 0x44, 0x2D};
const  char *BLE_SET_NAME = "TTM:REN-";
char BLE_DEF_NAME[] = "BMS-Dsp";

char BLE_GET_NAME[] = "TTM:NAM-?";
char BLE_READ_NAME[BLE_NAME_LEN] = {0,};